/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/24 21:20
  *
  * @file       hd_24cxx.h
  * @brief      Header file of 24CXX hardware driver.
  *
  * @note       This file contains the 24CXX object declaration.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/24     Chris        the first version
  *
  ******************************************************************************
  */


#ifndef JLC_SKY_24CXX_H
#define JLC_SKY_24CXX_H

#include "stm32f407xx.h"
#include <pd_i2c.h>
#include "drivers.h"

typedef struct AT24CXXDef AT24CXX;

struct AT24CXXDef {
    I2C *i2c;

    void (*init)(AT24CXX *this);

    void (*read)(AT24CXX *this, uint16_t address, uint8_t *dat, uint8_t len);

    void (*write)(AT24CXX *this, uint16_t address, uint8_t *dat, uint8_t len);
};

extern const struct AT24CXXClass {
    AT24CXX *(*build)(I2C *i2c);
} AT24CXXBuilder;


#define AT24CXX_ADDRESS 0x54

#endif //JLC_SKY_24CXX_H
